package com.yoda.mall.admin.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yoda.mall.api.OrderReturnReasonApi;
import com.yoda.mall.model.entity.oms.OrderReturnReason;
import com.yoda.mall.model.entity.sms.HomeAdvertise;
import com.yoda.mall.model.vo.PageResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class OrderReturnReasonService {
    @DubboReference
    private OrderReturnReasonApi orderReturnReasonApi;
    public void createOrderReturnReason(OrderReturnReason orderReturnReason) {
        orderReturnReason.setCreateTime(LocalDateTime.now());
        orderReturnReasonApi.createOrderReturnReason(orderReturnReason);
    }

    public void deleteOrderReturnReason(List<Long> ids) {
        orderReturnReasonApi.deleteOrderReturnReasonByIds(ids);
    }

    public PageResult<OrderReturnReason> orderReturnReasonList(Integer pageNum, Integer pageSize) {
        Page<OrderReturnReason> page = orderReturnReasonApi.getOrderReturnReasonListPage(pageNum, pageSize);
        return new PageResult<>((int) page.getCurrent(), (int) page.getSize(), (int) page.getTotal(), page.getRecords());
    }

    public void updateOrderReturnReasonStatus(List<Long> ids, Integer status) {
        orderReturnReasonApi.updateOrderReturnReasonStatusByIds(ids,status);
    }

    public void updateOrderReturnReason(Long id, OrderReturnReason orderReturnReason) {
        orderReturnReason.setId(id);
        orderReturnReasonApi.updateOrderReturnReason(orderReturnReason);
    }

    public OrderReturnReason getOrderReturnReason(Long id) {
        return orderReturnReasonApi.getOrderReturnReasonById(id);
    }
}
